<script setup>
import { ref } from 'vue'

const projects = ref([
  {
    id: 1,
    title: '电子音乐视觉化',
    thumbnail: 'https://placekitten.com/400/225',
    duration: '3:45',
    style: 'electronic',
    visualType: 'wave',
    likes: 156,
    views: 1200,
    createdAt: '2024-03-15'
  },
  {
    id: 2,
    title: '爵士乐动态效果',
    thumbnail: 'https://placekitten.com/401/225',
    duration: '4:20',
    style: 'jazz',
    visualType: 'particles',
    likes: 89,
    views: 750,
    createdAt: '2024-03-18'
  }
])

const visualStyles = [
  { id: 'all', name: '全部' },
  { id: 'wave', name: '波形' },
  { id: 'particles', name: '粒子' },
  { id: 'spectrum', name: '频谱' },
  { id: 'geometric', name: '几何' }
]

const currentStyle = ref('all')
</script>

<template>
  <div class="music-studio">
    <div class="studio-header">
      <h1>我的作品</h1>
      <div class="style-filters">
        <button 
          v-for="style in visualStyles"
          :key="style.id"
          :class="['style-btn', currentStyle === style.id ? 'active' : '']"
          @click="currentStyle = style.id"
        >
          {{ style.name }}
        </button>
      </div>
    </div>

    <div class="projects-grid">
      <div v-for="project in projects" 
           :key="project.id" 
           class="project-card">
        <div class="project-thumbnail">
          <img :src="project.thumbnail" :alt="project.title">
          <span class="duration">{{ project.duration }}</span>
          <div class="play-overlay">
            <span class="play-icon">▶️</span>
          </div>
        </div>
        
        <div class="project-info">
          <h3>{{ project.title }}</h3>
          <div class="project-meta">
            <span class="style-tag">{{ project.style }}</span>
            <span class="visual-type">{{ project.visualType }}</span>
          </div>
          
          <div class="project-stats">
            <span>
              <i>👁️</i> {{ project.views }}
            </span>
            <span>
              <i>❤️</i> {{ project.likes }}
            </span>
            <span>{{ project.createdAt }}</span>
          </div>
          
          <div class="project-actions">
            <button class="action-btn edit">
              <span>✏️</span>
              编辑
            </button>
            <button class="action-btn share">
              <span>📤</span>
              分享
            </button>
            <button class="action-btn preview">
              <span>👀</span>
              预览
            </button>
          </div>
        </div>
      </div>
    </div>

    <div class="visualization-preview">
      <div class="preview-canvas">
        <!-- 这里可以放置音频可视化预览 -->
        <div class="placeholder-visual">
          <div class="wave-bar"></div>
          <div class="wave-bar"></div>
          <div class="wave-bar"></div>
          <div class="wave-bar"></div>
          <div class="wave-bar"></div>
        </div>
      </div>
      <div class="preview-controls">
        <button class="control-btn">⏮️</button>
        <button class="control-btn large">▶️</button>
        <button class="control-btn">⏭️</button>
      </div>
    </div>
  </div>
</template>

<style scoped>
.music-studio {
  display: grid;
  gap: 2rem;
}

.studio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.studio-header h1 {
  font-size: 2rem;
  color: var(--text-primary);
}

.style-filters {
  display: flex;
  gap: 1rem;
}

.style-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 20px;
  background: white;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s;
}

.style-btn.active {
  background: var(--primary-color);
  color: white;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 2rem;
}

.project-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s;
}

.project-card:hover {
  transform: translateY(-5px);
}

.project-thumbnail {
  position: relative;
  height: 200px;
}

.project-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.duration {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.project-thumbnail:hover .play-overlay {
  opacity: 1;
}

.play-icon {
  font-size: 3rem;
}

.project-info {
  padding: 1.5rem;
}

.project-meta {
  display: flex;
  gap: 1rem;
  margin: 0.5rem 0;
}

.style-tag, .visual-type {
  background: #f0f1fe;
  color: var(--primary-color);
  padding: 0.2rem 0.8rem;
  border-radius: 12px;
  font-size: 0.9rem;
}

.project-stats {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 1rem 0;
}

.project-actions {
  display: flex;
  gap: 1rem;
}

.action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.action-btn.edit {
  background: #f0f1fe;
  color: var(--primary-color);
}

.action-btn.share {
  background: #f0fdf4;
  color: #22c55e;
}

.action-btn.preview {
  background: #fef3f2;
  color: #ef4444;
}

.visualization-preview {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  margin-top: 2rem;
}

.preview-canvas {
  height: 200px;
  background: #f0f1fe;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.placeholder-visual {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.wave-bar {
  width: 4px;
  height: 40px;
  background: var(--primary-color);
  border-radius: 2px;
  animation: wave 1s infinite ease-in-out;
}

.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { height: 40px; }
  50% { height: 80px; }
}

.preview-controls {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
}

.control-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.3s;
}

.control-btn.large {
  font-size: 2rem;
}

.control-btn:hover {
  transform: scale(1.1);
}
</style> 